package com.example.ItPhotoAlbumCloud.converter;


import com.example.ItPhotoAlbumCloud.dto.ItPhotoAlbumCloudUserDTO;
import com.example.ItPhotoAlbumCloud.entity.ItPhotoAlbumCloudUserDO;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 云相册用户模型转换器
 * 小仙 创建人 2023-03-11 14:36:11
 */
public class ItPhotoAlbumCloudUserConverter {

    /**
     * dto转do
     * @param source
     * return do模型
     */
    public static ItPhotoAlbumCloudUserDO toDo(ItPhotoAlbumCloudUserDTO source){
        ItPhotoAlbumCloudUserDO target = new ItPhotoAlbumCloudUserDO();
        target.setId(source.getId());
        target.setCloudUserName(source.getCloudUserName());
        target.setCloudUserPassword(source.getCloudUserPassword());
        target.setDatae(source.getDatae());
        target.setLoggedInDevice (source.getLoggedInDevice ());
        target.setEmail(source.getEmail());
        return target;
    }

    /**
     * do转dto
     * @param source
     * return dto模型
     */
    public static ItPhotoAlbumCloudUserDTO toDto(ItPhotoAlbumCloudUserDO source){
        ItPhotoAlbumCloudUserDTO target = new ItPhotoAlbumCloudUserDTO();
        target.setId(source.getId());
        target.setCloudUserName(source.getCloudUserName());
        target.setCloudUserPassword(source.getCloudUserPassword());
        target.setDatae(source.getDatae());
        target.setLoggedInDevice (source.getLoggedInDevice ());
        target.setEmail(source.getEmail());
        return target;
    }

    /**
     * do list 转 dto
     * @param data
     * return list dto模型
     */
    public static List<ItPhotoAlbumCloudUserDTO> toDtoList(List<ItPhotoAlbumCloudUserDO> data){
        if (CollectionUtils.isEmpty(data)){
            return null;
        }
        List<ItPhotoAlbumCloudUserDTO> list = new ArrayList<>();
        for (ItPhotoAlbumCloudUserDO item : data){
            list.add(ItPhotoAlbumCloudUserConverter.toDto(item));
        }
        return list;
    }
}

